home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / 80X86 / DOS32V33.ZIP / EXAMPLES / EG4.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-08-25  |  2.1 KB  |  98 lines

  1. ;**************************************************************************
  2. ;  EG4.ASM
  3. ;
  4. ;  This example program will display all files in the current directory
  5. ;
  6. ;
  7. ; DOS32 assembly language example program
  8. ;**************************************************************************
  9. .386
  10. .model  flat
  11. .stack 200h
  12. .code
  13.  
  14. ASCIIZ_path     db  '*.*',0         ; String for search path
  15. PSP_Address     DD  0
  16.  
  17.  
  18. Start:                            ; program entry point
  19.  
  20.   ;
  21.   ;  Call the DOS's "Find first" service
  22.   ;
  23.         mov     edx,offset ASCIIZ_path
  24.         mov     cx,00000b
  25.         mov     ah,4Eh
  26.         int     21h
  27.         jc exit
  28.   ;
  29.   ; The file info is put in the DTA buffer which is initally located
  30.   ; at offset 80h in the PSP segment
  31.   ;
  32.  
  33.         mov     ax,0EE02h            ; Get DOS32 address information
  34.         int     31h
  35.         mov     PSP_Address,esi      ; Save the PSP pointer.
  36.  
  37.  
  38.  
  39. ;----- file display loop --------
  40. Find_next_loop:
  41.  
  42.    ;
  43.    ; Load EDI with pointer to the DTA buffer
  44.    ;
  45.         mov     edi,PSP_Address
  46.         add     edi,80h
  47.  
  48.  
  49.    ;
  50.    ; Print ASCIIZ string that was stored at offset 1E of the DTA buffer.
  51.    ;
  52.  
  53. str_loop:
  54.       mov al,[edi+1Eh]              ; get file name character from DTA
  55.       cmp al,0                      ; if zero the string has ended
  56.       jz string_end
  57.       call Print_Char               ; plot it
  58.       inc edi                       ; get next char
  59.       jmp str_loop                  ; loop around
  60.  
  61. string_end:
  62.  ;
  63.  ; Finished printing the ASCIIZ file name.   Now to carrage return
  64.  ;
  65.  
  66.        mov al,13
  67.        call Print_Char
  68.        mov al,10
  69.        call Print_Char
  70.  
  71. ;
  72. ;    Loop around and keep on calling DOS's "Find Next" service until there
  73. ; are no more files to find.
  74. ;
  75.        mov  ah,4Fh
  76.        int  21h
  77.        jnc Find_next_loop
  78.  
  79. exit:
  80.         mov     ax,4c00h                    ; Exit program
  81.         int     21h
  82.  
  83.  
  84.  
  85.  
  86.  ;
  87.  ; A procedure to send character to the standard output.
  88.  ;
  89. Print_Char PROC
  90.         mov     ah,02h
  91.         mov     dl,al
  92.         int     21h
  93.         ret
  94. Print_Char ENDP
  95.  
  96.  
  97. END Start
  98.